#include <iostream>
#include <vector>

using namespace std;
class Solution
{
public:
    int balancedStringSplit(string s)
    {
        int ans = 0, d = 0;
        for (char ch : s)
        {
            ch == 'L' ? ++d : --d;
            if (d == 0)
            {
                ++ans;
            }
        }
        return ans;
    }
};
int main()
{
    Solution s;
    cout << s.balancedStringSplit("RLRRRLLRLL") << endl;
    system("pause");
    return 0;
}
